//
//  HYNetizenView.m
//  HaiYue
//
//  Created by skyline on 2018/2/9.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "HYNetizenView.h"
CGFloat const HYNetizenHeight = 30;

@interface HYNetizenView()
@property (nonatomic, strong) HYImageView *IMG;
@property (nonatomic, strong) HYLabel *nameLBL;
@property (nonatomic, strong) HYLabel *timeLBL;
@property (nonatomic, strong) HYLabel *floorLBL;
@end
@implementation HYNetizenView
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        
    }
    return self;
}

- (HYImageView *)IMG
{
    if (!_IMG)
    {
        _IMG = [[HYImageView alloc] initWithCornerRadius:GAP / 2.0];
        _IMG.image = [UIImage imageNamed:@"default_gameicon"];
        _IMG.bounds = CGRectMake(0, 0, HYNetizenHeight, HYNetizenHeight);
        [self addSubview:_IMG];
        [_IMG mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(GAP);
            make.top.equalTo(self);
            make.size.mas_equalTo(self.IMG.bounds.size);
        }];
    }
    return _IMG;
}

- (HYLabel *)nameLBL
{
    if (!_nameLBL)
    {
        _nameLBL = [[HYLabel alloc] initWithText:@"" textColor:TEXT_BLACK_COLOR textFont:[UIFont systemFontOfSize:DefaultFont]];
        [self addSubview:_nameLBL];
        [_nameLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.left.equalTo(self.IMG.mas_right).with.offset(GAP);
        }];
    }
    return _nameLBL;
}

- (HYLabel *)timeLBL
{
    if (!_timeLBL)
    {
        _timeLBL = [[HYLabel alloc] initWithText:@"" textColor:TEXT_GRAY_COLOR textFont:[UIFont systemFontOfSize:11 weight:UIFontWeightLight]];
        [self addSubview:_timeLBL];
        [_timeLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.IMG);
            make.left.equalTo(self.IMG.mas_right).with.offset(GAP);
        }];
    }
    return _timeLBL;
}

- (HYLabel *)floorLBL
{
    if (!_floorLBL)
    {
        _floorLBL = [[HYLabel alloc] initWithText:@"" textColor:TEXT_BLACK_COLOR textFont:[UIFont systemFontOfSize:DefaultFont]];
        [self addSubview:_floorLBL];
        [_floorLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).with.offset(-GAP);
            make.centerY.equalTo(self);
        }];
    }
    return _floorLBL;
}

- (void)setCommentModel:(HYCommentModel *)commentModel
{
    if (_commentModel != commentModel)
    {
        _commentModel = commentModel;
        if ([_commentModel.avatar length]> 1)
            self.IMG.imageURL = _commentModel.avatar;
        else
            self.IMG.image = [UIImage imageNamed:@"default_gameicon"];
        self.nameLBL.text = self.commentModel.publisher;
        self.timeLBL.text = self.commentModel.createtime;
        self.floorLBL.text = [NSString stringWithFormat:@"%@楼",self.commentModel.floor];
    }
}
- (void)setReplyModel:(HYReplyModel *)replyModel
{
    if (_replyModel != replyModel)
    {
        _replyModel = replyModel;
        if ([_replyModel.avatar length]> 1)
            self.IMG.imageURL = _replyModel.avatar;
        else
            self.IMG.image = [UIImage imageNamed:@"default_gameicon"];
        self.nameLBL.text =_replyModel.publisher;
        self.timeLBL.text = _replyModel.createtime;
    }
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
